home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk8 / superlib / libsrc / fhprintf.asm < prev    next >
Assembly Source File  |  1995-03-18  |  2KB  |  64 lines

  1.  
  2. ;FHPRINTF.ASM
  3. ;
  4. ;  Handles formatted printing to Amiga file handles   w/ fhprintf
  5.  
  6. ;
  7. ;   Manx assembler FAR stmts.
  8.  
  9.  FAR code
  10.  FAR data
  11.  
  12.       xdef  _fhprintf
  13.       xref  _Write
  14.       xref  _LVORawDoFmt
  15.       xref  _SysBase
  16.  
  17. _fhprintf
  18.       jsr      xformat ;same thing
  19.       jsr      _Write
  20.       lea.l    268(A7),A7
  21.       rts
  22.  
  23.       ;XFORMAT takes a Xprintf(xx, cs, arg, arg...)  where xx is any
  24.       ;integer and returns (xx, buf, bytes) on the stack suitable for an
  25.       ;immediate call to xwrite() or Write().  The caller must deallocate
  26.       ;268 bytes from the stack when done.
  27.       ;
  28.       ; (oret)
  29.       ;  A2 A3 A4 A5 A6 RET FI BUF NUM <thebuffer> printfret fi cs args
  30.       ;  ^   ^       ^
  31.       ;  1   2       3
  32.  
  33.  
  34. xformat
  35.       move.l   A7,A0   ;sp now at pos. #3  A0 = pos #3
  36.       sub.l    #268,A7 ;sp now at pos. #2  SP = pos #2
  37.       move.l   (A0),(A7)  ;copy return address
  38.       move.l   8(A0),4(A7)  ;copy fi or fh  to FI
  39.       lea.l    16(A7),A1  ;address of buffer
  40.       move.l   A1,8(A7)   ;place inBUF
  41.       movem.l  A2-A6,-(A7)  ;save regs SP = pos #1
  42.       move.l   A1,A3   ;A3 = buffer pointer
  43.       lea.l    16(A0),A1  ;A1 = lea of printf arg list
  44.       move.l   12(A0),A0  ;A0 = control string
  45.       move.l   #_xc,A2 ;A2 = call vector
  46.  
  47.       move.l   _SysBase,A6  ;exec library call
  48.       jsr      _LVORawDoFmt(A6)
  49.  
  50.       move.l   28(A7),A3  ;buffer start
  51. loop  tst.b    (A3)+   ;find end of string
  52.       bne      loop
  53.       sub.l    28(A7),A3  ;get string length
  54.       subq.l   #1,A3
  55.       move.l   A3,32(A7)  ;place inNUM
  56.       movem.l  (A7)+,A2-A6  ;restore registers used
  57.       rts
  58.  
  59. _xc
  60.       move.b   D0,(A3)+
  61.       rts
  62.  
  63.  
  64.